import 'package:myapp/entities/entities.dart';
import 'models.dart';


class Article {
  String slug;
  String title;
  String description;
  String body;
  List<String> tagList;
  DateTime createdAt;
  DateTime updatedAt;
  bool favorited;
  int favoritesCount;
  MyUser author;

  Article(
      {required this.slug,
      required this.title,
      required this.description,
      required this.body,
      required this.tagList,
      required this.createdAt,
      required this.updatedAt,
      required this.favorited,
      required this.favoritesCount,
      required this.author});
  ArticleEntity toEntity() {
    return ArticleEntity(
        slug: slug,
        title: title,
        description: description,
        body: body,
        tagList: tagList,
        createdAt: createdAt,
        updatedAt: updatedAt,
        favorited: favorited,
        favoritesCount: favoritesCount,
        author: author);
  }

  static Article fromEntity(ArticleEntity entity) {
    return Article(
        slug: entity.slug,
        title: entity.title,
        description: entity.description,
        body: entity.body,
        tagList: entity.tagList,
        createdAt: entity.createdAt,
        updatedAt: entity.updatedAt,
        favorited: entity.favorited,
        favoritesCount: entity.favoritesCount,
        author: entity.author);
  }

  
}
